<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="title">
            <h2><a href="#" class="back" onclick="history.go(-1)"/>Editar Campus</h2>
        </ui:define>

        <ui:define name="body">
            <h:form id="secretariaForm" enctype="multipart/form-data">            
                <p:messages id="messages" closable="true" showDetail="true" autoUpdate="true"  />
                <p:panel styleClass="container_24 clearfix">

                    <p:outputLabel value="Nome:" styleClass="grid_3"/>
                    <p:inputText styleClass="grid_20" value="#{managerPesquisarSecretaria.secretariaEditar.nome}"/>
                    <div class="clear"/>

                    <p:outputLabel value="Diretor:" styleClass="grid_3"/>
                    <p:inputText styleClass="grid_20" value="#{managerPesquisarSecretaria.secretariaEditar.nomeSecretario}"/>
                    <div class="clear"/>

                    <p:outputLabel value="Sigla:" styleClass="grid_3"/>
                    <p:inputText styleClass="grid_20" value="#{managerPesquisarSecretaria.secretariaEditar.sgl}"/>
                    <div class="clear"/>

                    <p:outputLabel value="Descrição:" styleClass="grid_3"/>
                    <p:inputTextarea styleClass="grid_20" value="#{managerPesquisarSecretaria.secretariaEditar.descricao}"/>

                </p:panel> 


                <p:panel id="panelSetor" styleClass="container_24 clearfix">
                    <h2>Setor</h2>
                    <br/>
                    <p:outputLabel value="Nome:" styleClass="grid_3"/>
                    <p:inputText styleClass="grid_18" value="#{managerPesquisarSecretaria.setorEditar.nome}"/>
                    <div class="clear"/>

                    <div class="buttonAction"> 
                        <p:commandButton styleClass="ui-priority-primary"  
                                         icon="ui-icon-circle-plus" value="Adicionar" update="panelSetor, tableSetor"
                                         actionListener="#{managerPesquisarSecretaria.add()}"/>
                    </div>
                    <div class="clear"/>

                    <p:dataTable id="tableSetor" var="item" value="#{managerPesquisarSecretaria.setoresEditar}" 
                                 styleClass="grid_24" rowIndexVar="rowid" 
                                 style="white-space: pre-wrap;"
                                 rowKey="#{item.id}" rows="5" paginator="true"  
                                 paginatorPosition="bottom" emptyMessage="Nenhum registro">  
                        <f:facet name="header">
                            <p:outputLabel value="Setores" />
                        </f:facet>
                        <p:column headerText="Ação" width="10px;">
                            <p:commandButton icon="ui-icon-pencil" update=":secretariaForm:panelSetor" 
                                             actionListener="#{managerPesquisarSecretaria.edit(item)}"/>
                            <p:commandButton title="Excluir" oncomplete="dlg.show();" 
                                             update="@form" icon="ui-icon-trash">
                                <f:setPropertyActionListener target="#{managerPesquisarSecretaria.setorExcluir}" value="#{item}" />
                            </p:commandButton>
                        </p:column>
                        <p:column headerText="Nome">
                            <p:outputLabel value="#{item.nome}"/>
                        </p:column>

                    </p:dataTable>
                </p:panel>

                <p:panel styleClass="container_24 clearfix">
                    <div class="buttonAction">
                        <p:commandButton 
                            styleClass="ui-priority-primary"
                            value="Atualizar" icon="ui-icon-disk" update="@form" 
                            actionListener="#{managerPesquisarSecretaria.atualizar()}" />
                        <p:button value="Voltar" icon="ui-icon-circle-arrow-w" href="indexsecretaria.xhtml" />
                    </div>
                    <br/>
                </p:panel>

                <p:panel id="paneldlg">
                    <p:dialog id="iddlg" header="Exclusão" widgetVar="dlg" modal="true" 
                              appendToBody="true" closable="false" height="20"
                              showEffect="fade" hideEffect="fade" resizable="false">  
                        <h:outputText value="Deseja excluir esse registro ?" /> <br/> 
                        <f:facet name="footer">

                            <div class="buttonAction">
                                <p:commandButton value="Sim" id="idb"
                                                 actionListener="#{managerPesquisarSecretaria.removerSetor()}"
                                                 update=":secretariaForm:tableSetor, @form"
                                                 icon="ui-icon-check" onsuccess="dlg.hide()" />
                                <p:commandButton value="Não" process="@this" onclick="dlg.hide()" icon="ui-icon-close" />
                            </div>

                        </f:facet>
                    </p:dialog>   
                </p:panel>

            </h:form>
        </ui:define>
    </ui:composition>
</html>
